home *** CD-ROM | disk | FTP | other *** search
- Path: news.tu-chemnitz.de!news
- From: hfst@hrz.tu-chemnitz.de (Hans Steffani)
- Newsgroups: comp.lang.c
- Subject: Re: How to link a FORTRAN subroutine into c program?
- Date: 18 Jan 96 07:14:41 GMT
- Organization: University of Technology Chemnitz, FRG
- Message-ID: <4dksak$k71@pyrrhus-f.hrz.tu-chemnitz.de>
- References: <4dj7bf$mud@usenet.ucs.indiana.edu>
- NNTP-Posting-Host: mmu.hrz.tu-chemnitz.de
-
- ymao@copper.ucs.indiana.edu (Y.Mao) writes:
-
-
- >I am writing programs on DEC Alpha/OSF1. Sometimes I need to link a C
- >function into a FORTRAN program, somehow I figured it out. However, I
- >don't know how to link a FORTRAN subroutine as a C function.( I mean,
- >call a FORTRAN subroutine in a C program).
-
- This question is computer and compiler depending. Have a look
- at the section "mixed languages programming" in your documentations.
-
- However there a some rules which are often valid.
-
- You have to find out, which FORTRAN types are equivalent to
- which C types.
-
- C calls by value, FORTRAN by reference therefore pass the adresses
- of your arguments instead of your arguments.
-
- C may sort the arguments on the stack in a different way FORTRAN does.
- (C pushs the first argument as the last one FORTRAN as the first one)
-
- Arrays in FORTRAN are lined up by the first index as in C by the last
- index.
-
- Hans Friedrich Steffani
- --
- Hans Friedrich Steffani
- Institut fuer Elektrische Maschinen und Antriebe
- TU Chemnitz-Zwickau
- e-mail: hans.steffani@e-technik.tu-chemnitz.de
-